﻿Function.RegisterNamespace("Test.xUnit.js");

[Fixture, Skip("Need to find way to test these generically (e.g. in synchronous host engines)"), Trait("Integration")]
Test.xUnit.js.Async=function(){

    [Fact,  Async]
    function AsyncFactWithoutCallback(callback){
        return;
    }

    [Fact,  Async]
    function AsyncFactWithoutCallbackParameter(){
        return;
    }

    [Fact, Async, Trait("Phantom"), Data("http://google.com","http://bing.com","http://codeeeeeeeeplex.com")]
    function AsyncFact(callback,data){
        var webPage=require("webpage");
        var page=webPage.create();
        page.open(data,function(status){
            callback(function(){
                Assert.Equal("success",status);
            })
        });
    }

    [Fact,  Async]
    function PseudoAsyncFact(callback){
        callback(function(){
            Assert.True(true);
        });
    }

    [Fact, Async]
    function FailingAsyncFact(callback){
        callback(function(){Assert.True(false)});
    }

    [Fact, Async]
    function AsyncFactWithoutDelegate(callback){
        callback();
    }

    [Fact, Async]
    function AsyncFactWithAssertInMainThread(callback){
        callback(function(){
            Assert.Equal("success",status);
        });
        Assert.True(true);
    }

    [Fact,  Async]
    function ErroringAsyncFact(callback){
        callback(function(){
            x.x.x;
        });
    }

}